#include<bits/stdc++.h>
using namespace std;
int a[10010];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n,top=0,butt=10010,ans=0,killer=0;
    int q=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        top=max(a[i-1],a[i]);
        butt=min(a[i-1],a[i]);
    }
    for(top;top>=butt;top--){
        q=0;
        for(int j=1;j<=n;j++)
            if(a[j]==top)q++;
        if(killer<=q){
            ans+=(q-killer);
            killer=q;
        }
    }
    cout<<ans<<endl;
    return 0;
}
